Proper connect_port
[juce-lv2.git] / juce / source / extras / the jucer / src / model / jucer_PaintRoutine.h
blobd5064bddf29b387c14d81dd829a0561a26162e1b
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCER_PAINTROUTINE_JUCEHEADER__
27 #define __JUCER_PAINTROUTINE_JUCEHEADER__
29 #include "paintelements/jucer_PaintElement.h"
30 class JucerDocument;
31 class PathPoint;
34 //==============================================================================
35 /**
36 Contains a set of PaintElements that constitute some kind of paint() method.
39 class PaintRoutine
41 public:
42 //==============================================================================
43 PaintRoutine();
44 ~PaintRoutine();
46 //==============================================================================
47 void changed();
48 bool perform (UndoableAction* action, const String& actionName);
50 //==============================================================================
51 int getNumElements() const throw() { return elements.size(); }
52 PaintElement* getElement (const int index) const throw() { return elements [index]; }
53 int indexOfElement (PaintElement* e) const throw() { return elements.indexOf (e); }
54 bool containsElement (PaintElement* e) const throw() { return elements.contains (e); }
56 //==============================================================================
57 void clear();
58 PaintElement* addElementFromXml (const XmlElement& xml, const int index, const bool undoable);
59 PaintElement* addNewElement (PaintElement* elementToCopy, const int index, const bool undoable);
60 void removeElement (PaintElement* element, const bool undoable);
62 void elementToFront (PaintElement* element, const bool undoable);
63 void elementToBack (PaintElement* element, const bool undoable);
65 const Colour getBackgroundColour() const throw() { return backgroundColour; }
66 void setBackgroundColour (const Colour& newColour) throw();
68 void fillWithBackground (Graphics& g, const bool drawOpaqueBackground);
69 void drawElements (Graphics& g, const Rectangle<int>& relativeTo);
71 void dropImageAt (const File& f, int x, int y);
73 //==============================================================================
74 SelectedItemSet <PaintElement*>& getSelectedElements() throw() { return selectedElements; }
75 SelectedItemSet <PathPoint*>& getSelectedPoints() throw() { return selectedPoints; }
77 static const char* const clipboardXmlTag;
78 void copySelectedToClipboard();
79 void paste();
80 void deleteSelected();
81 void selectAll();
83 void selectedToFront();
84 void selectedToBack();
86 void groupSelected();
87 void ungroupSelected();
89 void startDragging (const Rectangle<int>& parentArea);
90 void dragSelectedComps (int dxFromDragStart, int dyFromDragStart, const Rectangle<int>& parentArea);
91 void endDragging();
93 void bringLostItemsBackOnScreen (const Rectangle<int>& parentArea);
95 //==============================================================================
96 void setDocument (JucerDocument* const document_) { document = document_; }
97 JucerDocument* getDocument() const throw() { return document; }
99 //==============================================================================
100 static const char* xmlTagName;
101 XmlElement* createXml() const;
102 bool loadFromXml (const XmlElement& xml);
104 void fillInGeneratedCode (GeneratedCode& code, String& paintMethodCode) const;
106 //==============================================================================
107 private:
108 OwnedArray <PaintElement> elements;
109 SelectedItemSet <PaintElement*> selectedElements;
110 SelectedItemSet <PathPoint*> selectedPoints;
111 JucerDocument* document;
113 Colour backgroundColour;
115 friend class DeleteElementAction;
116 friend class FrontOrBackElementAction;
117 void moveElementZOrder (int oldIndex, int newIndex);
120 #endif // __JUCER_PAINTROUTINE_JUCEHEADER__